import os


class Config:
    """
    配置文件
    """
    API_PREFIX = "/api/p/v1/cv/"
    PYTHON_PORT = 6001
    TOKEN = "nernlp"
    DATA_HOME = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'data'))
    ISGPU = False
    GPU = "0,1"
    # 图像分类
    CLASS_BATCH_SIZE = 32
    CLASS_TARGET_SIZE = (448,448,3)
    CLASS_NUMBER = 1000
    CLASS_CUSTOM = [str(i) for i in range(CLASS_NUMBER)]
    CLASS_LR = 1e-4
    CLASS_EPOCHS = 20
    CLASS_MODEL_HOME = os.path.join(DATA_HOME, 'class/model_vgg16.h5')
    CLASS_TRAIN_DATA = os.path.join(DATA_HOME, 'class/train')
    CLASS_TEST_DATA = os.path.join(DATA_HOME, 'class/val')


CONFIG = Config()
# 读取环境变量,更新到Config后，以和容器一起使用
for k in os.environ:
    if k in Config.__dict__:
        print('use environ var:', k, os.environ.get(k))
        setattr(Config, k, os.environ.get(k))
CONFIG = Config()
for k in os.environ:
    if k in CONFIG.__dict__:
        print('use environ var:', k, os.environ.get(k))
        CONFIG.__dict__[k] = os.environ.get(k)
